package com.geor.gcv.core.model;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.opencv.core.Mat;

import com.geor.gcv.core.util.DataTool;

/**
 * 预处理结果参数
 * 
 * @author geor.lusongnan
 * 
 */
@Deprecated
public class Result {
	private Mat stepMat;
	private Mat cutMat;
	private Mat src;

	private List<Integer> rows;
	private List<Integer> cols;
	private List<List<Integer>> cols_cols;
	private List<Mat> mats = new ArrayList<Mat>();
	private int blockSize = 0;
	private int constValue = 0;
	private String path;
	private int index = 0;
	private boolean isSuccess;
	private String name;

	private Map<Area, Mat> matMaps = new LinkedHashMap<Area, Mat>();

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public boolean isSuccess() {
		return isSuccess;
	}

	public void setSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	public Mat getStepMat() {
		return stepMat;
	}

	public void setStepMat(Mat stepMat) {
		this.stepMat = stepMat;
	}

	public List<Mat> getMats() {
		return mats;
	}

	public void setMats(List<Mat> mats) {
		this.mats = mats;
	}

	public int getBlockSize() {
		return blockSize;
	}

	public void setBlockSize(int blockSize) {
		this.blockSize = blockSize;
	}

	public int getConstValue() {
		return constValue;
	}

	public void setConstValue(int constValue) {
		this.constValue = constValue;
	}

	public List<Integer> getRows() {
		return rows;
	}

	public void setRows(List<Integer> rows) {
		if (stepMat != null) {
			int row = 0;
			if (rows.size() >= 2) {
				row = DataTool.getListPoorMaxValue(rows);
				int start = rows.get(row);
				int end = rows.get(row + 1);
				rows.clear();
				rows.add(start);
				rows.add(end);
			} else if (rows.size() == 1) {
				rows.add((int) stepMat.size().height - 2);
			} else {
				rows.add(1);
				rows.add((int) stepMat.size().height - 2);
			}
		}
		this.rows = rows;
	}

	public List<Integer> getCols() {
		return cols;
	}

	public void setCols(List<Integer> cols) {
		this.cols = cols;
	}

	public Mat getCutMat() {
		return cutMat;
	}

	public void setCutMat(Mat cutMat) {
		this.cutMat = cutMat;
	}

	public Mat getSrc() {
		return src;
	}

	public void setSrc(Mat src) {
		this.src = src;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public int getIndex() {
		return index;
	}

	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer("\n");
		buffer.append("rows:").append(rows).append("\n").append("cols:").append(cols).append("\n").append("mats:")
				.append(mats.size()).append("\n").append("srcPath:").append(path).append("\n");
		return buffer.toString();
	}

	public Map<Area, Mat> getMatMaps() {
		return matMaps;
	}

	public void setMatMaps(Map<Area, Mat> matMaps) {
		this.matMaps = matMaps;
	}

	@Override
	public Result clone() {
		Result temp = new Result();
		temp.setBlockSize(this.getBlockSize());
		temp.setConstValue(this.getConstValue());
		temp.setCols(this.getCols());
		temp.setRows(this.getRows());
		temp.setCutMat(this.getCutMat().clone());
		temp.setSrc(this.getSrc().clone());
		temp.setStepMat(this.getStepMat().clone());
		temp.setMats(this.getMats());
		temp.setPath(this.getPath());
		temp.setIndex(this.getIndex());
		temp.setSuccess(this.isSuccess());
		temp.setMatMaps(getMatMaps());
		return temp;
	}

	public List<List<Integer>> getCols_cols() {
		return cols_cols;
	}

	public void setCols_cols(List<List<Integer>> cols_cols) {
		this.cols_cols = cols_cols;
	}
}
